/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-17 18:08:20
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-18 07:39:53
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/components/animation_text.dart';
import 'package:flutter_data_center/model/wristband/wristband_model.dart';
import 'package:flutter_data_center/screens/wristband/detail/wristband_detail_screen.dart';
import 'package:flutter_data_center/utills/color_utils.dart';
import 'package:flutter_data_center/utills/navigator_utils.dart';
import 'package:line_icons/line_icons.dart';

class WristbandItem extends StatelessWidget {
  const WristbandItem({Key key, this.wristband, this.index}) : super(key: key);
  final WristbandModel wristband;
  final int index;

  @override
  Widget build(BuildContext context) => InkWell(
        onTap: () {
          NavigatorUtils.pushPageByFade(
            context: context,
            targetPage: WristbandDetailScreen(tag: "$index"),
            isReplace: false,
          );
        },
        splashColor: Theme.of(context).primaryColor.withOpacity(0.2),
        child: ListTile(
          isThreeLine: false,
          minLeadingWidth: 34,
          leading: Hero(
            tag: "$index",
            child: ClipOval(
              child: Image.network(
                wristband.avatar,
                fit: BoxFit.cover,
                width: 34,
                height: 34,
              ),
            ),
          ),
          title: Text(
            wristband.name,
            style: TextStyle(
              color: Colors.black,
              fontSize: 14,
            ),
          ),
          subtitle: Text(
            wristband.address,
            style: TextStyle(
              color: gColor('#696868'),
              fontSize: 12,
            ),
          ),
          trailing: Container(
            width: 100,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                AnimText(
                  number: wristband.rate,
                  style: TextStyle(
                    fontSize: 24,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                SizedBox(width: 16),
                Column(
                  children: [
                    AnimText(
                      number: wristband.heart,
                      style: TextStyle(
                        fontSize: 18,
                        color: gColor("#A4A4A4"),
                      ),
                    ),
                    Icon(
                      LineIcons.heartbeat,
                      size: 18,
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      );
}
